import type { BasicConfigOption } from '@/views/tools/nginx/nginx-info.ts'

const proxyCommonOptions : BasicConfigOption[] = [
  { code: 'proxy_bind', name: 'proxy_bind' },
  { code: 'proxy_buffer_size', name: 'proxy_buffer_size' },
  { code: 'proxy_buffering', name: 'proxy_buffering' },
  { code: 'proxy_buffers', name: 'proxy_buffers' },
  { code: 'proxy_busy_buffers_size', name: 'proxy_busy_buffers_size' },
  { code: 'proxy_cache', name: 'proxy_cache' },
  { code: 'proxy_cache_background_update', name: 'proxy_cache_background_update' },
  { code: 'proxy_cache_bypass', name: 'proxy_cache_bypass' },
  { code: 'proxy_cache_convert_head', name: 'proxy_cache_convert_head' },
  { code: 'proxy_cache_key', name: 'proxy_cache_key' },
  { code: 'proxy_cache_lock', name: 'proxy_cache_lock' },
  { code: 'proxy_cache_lock_age', name: 'proxy_cache_lock_age' },
  { code: 'proxy_cache_lock_timeout', name: 'proxy_cache_lock_timeout' },
  { code: 'proxy_cache_max_range_offset', name: 'proxy_cache_max_range_offset' },
  { code: 'proxy_cache_methods', name: 'proxy_cache_methods' },
  { code: 'proxy_cache_min_uses', name: 'proxy_cache_min_uses' },
  { code: 'proxy_cache_purge', name: 'proxy_cache_purge' },
  { code: 'proxy_cache_revalidate', name: 'proxy_cache_revalidate' },
  { code: 'proxy_cache_use_stale', name: 'proxy_cache_use_stale' },
  { code: 'proxy_cache_valid', name: 'proxy_cache_valid' },
  { code: 'proxy_connect_timeout', name: 'proxy_connect_timeout' },
  { code: 'proxy_cookie_domain', name: 'proxy_cookie_domain' },
  { code: 'proxy_cookie_flags', name: 'proxy_cookie_flags' },
  { code: 'proxy_cookie_path', name: 'proxy_cookie_path' },
  { code: 'proxy_force_ranges', name: 'proxy_force_ranges' },
  { code: 'proxy_headers_hash_bucket_size', name: 'proxy_headers_hash_bucket_size' },
  { code: 'proxy_headers_hash_max_size', name: 'proxy_headers_hash_max_size' },
  { code: 'proxy_hide_header', name: 'proxy_hide_header' },
  { code: 'proxy_http_version', name: 'proxy_http_version' },
  { code: 'proxy_ignore_client_abort', name: 'proxy_ignore_client_abort' },
  { code: 'proxy_ignore_headers', name: 'proxy_ignore_headers' },
  { code: 'proxy_intercept_errors', name: 'proxy_intercept_errors' },
  { code: 'proxy_limit_rate', name: 'proxy_limit_rate' },
  { code: 'proxy_max_temp_file_size', name: 'proxy_max_temp_file_size' },
  { code: 'proxy_method', name: 'proxy_method' },
  { code: 'proxy_next_upstream', name: 'proxy_next_upstream' },
  { code: 'proxy_next_upstream_timeout', name: 'proxy_next_upstream_timeout' },
  { code: 'proxy_next_upstream_tries', name: 'proxy_next_upstream_tries' },
  { code: 'proxy_no_cache', name: 'proxy_no_cache' },
  { code: 'proxy_pass_header', name: 'proxy_pass_header' },
  { code: 'proxy_pass_request_body', name: 'proxy_pass_request_body' },
  { code: 'proxy_pass_request_headers', name: 'proxy_pass_request_headers' },
  { code: 'proxy_pass_trailers', name: 'proxy_pass_trailers' },
  { code: 'proxy_read_timeout', name: 'proxy_read_timeout' },
  { code: 'proxy_redirect', name: 'proxy_redirect' },
  { code: 'proxy_request_buffering', name: 'proxy_request_buffering' },
  { code: 'proxy_send_lowat', name: 'proxy_send_lowat' },
  { code: 'proxy_send_timeout', name: 'proxy_send_timeout' },
  { code: 'proxy_set_body', name: 'proxy_set_body' },
  { code: 'proxy_set_header', name: 'proxy_set_header' },
  { code: 'proxy_socket_keepalive', name: 'proxy_socket_keepalive' },
  { code: 'proxy_ssl_certificate', name: 'proxy_ssl_certificate' },
  { code: 'proxy_ssl_certificate_cache', name: 'proxy_ssl_certificate_cache' },
  { code: 'proxy_ssl_certificate_key', name: 'proxy_ssl_certificate_key' },
  { code: 'proxy_ssl_ciphers', name: 'proxy_ssl_ciphers' },
  { code: 'proxy_ssl_conf_command', name: 'proxy_ssl_conf_command' },
  { code: 'proxy_ssl_crl', name: 'proxy_ssl_crl' },
  { code: 'proxy_ssl_key_log', name: 'proxy_ssl_key_log' },
  { code: 'proxy_ssl_name', name: 'proxy_ssl_name' },
  { code: 'proxy_ssl_password_file', name: 'proxy_ssl_password_file' },
  { code: 'proxy_ssl_protocols', name: 'proxy_ssl_protocols' },
  { code: 'proxy_ssl_server_name', name: 'proxy_ssl_server_name' },
  { code: 'proxy_ssl_session_reuse', name: 'proxy_ssl_session_reuse' },
  { code: 'proxy_ssl_trusted_certificate', name: 'proxy_ssl_trusted_certificate' },
  { code: 'proxy_ssl_verify', name: 'proxy_ssl_verify' },
  { code: 'proxy_ssl_verify_depth', name: 'proxy_ssl_verify_depth' },
  { code: 'proxy_store', name: 'proxy_store' },
  { code: 'proxy_store_access', name: 'proxy_store_access' },
  { code: 'proxy_temp_file_write_size', name: 'proxy_temp_file_write_size' },
  { code: 'proxy_temp_path', name: 'proxy_temp_path' },
]

const gzipCommonOptions: BasicConfigOption[] = [
  { code: 'gzip', name: 'gzip' },
  { code: 'gzip_buffers', name: 'gzip_buffers' },
  { code: 'gzip_comp_level', name: 'gzip_comp_level' },
  { code: 'gzip_disable', name: 'gzip_disable' },
  { code: 'gzip_http_version', name: 'gzip_http_version' },
  { code: 'gzip_min_length', name: 'gzip_min_length' },
  { code: 'gzip_proxied', name: 'gzip_proxied' },
  { code: 'gzip_types', name: 'gzip_types' },
  { code: 'gzip_vary', name: 'gzip_vary' },
]

export const httpBasicOptions: BasicConfigOption[] = [
  { code: 'root', name: 'root' },
  { code: 'deny', name: 'deny' },
  { code: 'allow', name: 'allow' },
  { code: 'include', name: 'include' },
  { code: 'api', name: 'api', description: '提供一些接口， 反应当前nginx 状态' },
  { code: 'default_type', name: 'default_type' },
  { code: 'access_log', name: 'access_log' },
  { code: 'log_format', name: 'log_format' },
  { code: 'sendfile', name: 'sendfile' },
  { code: 'tcp_nopush', name: 'tcp_nopush' },
  { code: 'keepalive_timeout', name: 'keepalive_timeout' },
  { code: 'access_log', name: 'access_log' },
  {
    code: 'log_format',
    name: 'log_format',
    description: 'https://nginx.org/en/docs/http/ngx_http_log_module.html',
  },
  { code: 'open_log_file_cache', name: 'open_log_file_cache' },
  ...proxyCommonOptions,
  { code: 'proxy_cache_path', name: 'proxy_cache_path' },
  { code: 'rewrite_log', name: 'rewrite_log' },
  ...gzipCommonOptions,
]


export const httpServerBasicOptions : BasicConfigOption[] = [
  { code: 'root', name: 'root' },
  ...proxyCommonOptions,
  { code: 'rewrite', name: 'rewrite' },
  { code: 'rewrite_log', name: 'rewrite_log' },
  ...gzipCommonOptions,
]

export const httpLocationBasicOptions: BasicConfigOption[] = [
  { code: 'root', name: 'root' },
  { code: 'proxy_pass', name: 'proxy_pass' },
  ...proxyCommonOptions,
  ...gzipCommonOptions,
]
export const httpUpstreamBasicOptions : BasicConfigOption[] = [
  { code: 'server', name: 'server' },
  { code: 'zone', name: 'zone' },
  { code: 'ip_hash', name: 'ip_hash' },
  { code: 'keepalive', name: 'keepalive' },
  { code: 'keepalive_time', name: 'keepalive_time' },
  { code: 'keepalive_requests', name: 'keepalive_requests' },
  { code: 'least_conn', name: 'least_conn' },
  { code: 'least_time', name: 'least_time' },
  { code: 'queue', name: 'queue' },
  { code: 'random', name: 'random' },
  { code: 'resolver', name: 'resolver' },
  { code: 'resolver_timeout', name: 'resolver_timeout' },
]
